'use strict';

/**
 * @param {Egg.Application} app - egg application
 * 路由处理接口请求,或render模板引擎等
 */
module.exports = app => {
  app.once('server', server => {
    console.log('====websocket')
  });
  app.on('error', (err, ctx) => {
    console.log('===report error')
  });
  app.on('request', ctx => {
    console.log('===log receive request')
  });
  app.on('response', ctx => {
    // ctx.starttime is set by framework
    const used = Date.now() - ctx.starttime;
    console.log('=====log total cost')
  });

  const { router, controller } = app;
  router.get('/', controller.home.index);
  router.get('/health', controller.home.health);
};
